﻿<!--
var friend = {
    info:{
        sendapply:
        function(uid, note)
        {
            $.post("/relationship/ajax_friendapply", {UserId:uid, strInfo:note}, function(data) {friend.info.frienapply_callback(data);}, "TEXT" );
        },
        frienapply_callback:
        function(data)
        {
            if (data == "done")
            {
                CloseBox();
                friend.layer.showsendapplydone();
            }
            else
            {
                if (data == "isfriend")
                {
                    CloseBox();
                    friend.layer.showisfriend();
                }
                else
                {
                    window.alert("数据错误");
                }
            }
        },
        changesetting:
        function(rid, groupinfo, note)
        {
            $.post("/relationship/ajax_changefriendsetting", {rid:rid, groupinfo:groupinfo, note:note}, function(data) {friend.info.changesetting_callback(data);}, "TEXT" );
        },
        changesetting_callback:
        function(data)
        {
            CloseBox();
            if (data == "done") window.location.reload();
            else window.alert("数据错误");
        },
        deletefriend:
        function(fid)
        {
            $.post("/relationship/ajax_deletefriend", {fid:fid}, function(data) {friend.info.deletefriend_callback(data);}, "TEXT" );
        },
        deletefriend_callback:
        function(data)
        {
            CloseBox();
            if (data == "done") window.location.reload();
            else window.alert("数据错误");
        }
    },
	layer: {
	    showfriendapply:
	    function(uid)
	    {
	        OpenDialogBox("/Relationship/Layer_FriendApply?UserId=" + uid, "好友请求", 400, 
	            function() {
	                $("#idBoxConfirm").bind("click", function() {
	                    $("#idBoxConfirm").attr("disabled", "true");
	                    $("#idBoxCancel").attr("disabled", "true");
	                    $("#strInfo").attr("readonly", "true");
                        friend.info.sendapply(uid, $("#strInfo").val());
                    });
	            });
	    },
	    showchangesetting:
	    function(rid) {
	        OpenDialogBox("/Relationship/Layer_FriendSetting?rid=" + rid, "好友属性", 300,
	            function() {
	                $("#idBoxConfirm").bind("click", function() {
	                    var groupInfo = "";
                        var checked = $("input:checked");
                        if($("#note").val().length < 10)
                        {
                            $.each(checked, function(i,n) { if (groupInfo == "") groupInfo += this.value; else groupInfo += "," + this.value; });
                            friend.info.changesetting($("#rid").val(), groupInfo, $("#note").val());
                        }
                        else
                        {
                            $("#errormessage").html("您的好友备注信息过长,请尽量控制在10个字符以内！");
                        }
	                });
	            });
		},
		showdeletefriend:
		function(fid) {
	        OpenDialogBox("/Relationship/Layer_DeleteFriend?fid=" + fid, "删除好友", 400,
	        function() {
	                $("#idBoxConfirm").bind("click", function() {
	                    friend.info.deletefriend(fid);
	                });
	            });
		},
		showsendapplydone:
		function()
		{
		    OpenAlertBoxByText("已经成功发送好友请求，请耐心等待对方处理", "好友请求", 320);
		},
		showisfriend:
		function()
		{
		    OpenAlertBoxByText("你和对方已经是好友关系", "好友请求", 400);
		}
	}
}
-->